package com.xiaoxiong.text;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;

public class GetAttendanceInfo {
	private String Url = SchoolUrl.Attendance;
	private static String cookie;
	private Context context;
	private Handler postHandler;
	private String studentId;
	private StringHttp stringHttp;
	

	public GetAttendanceInfo(Context context, Handler postHandler) {
		super();
		this.context = context;
		this.stringHttp = new StringHttp(this.context);
		this.postHandler = postHandler;
		this.getCookie();
		this.getStudentId();
	}

	//获取cookies
	public void getCookie() {
		SharedPreferences sp_cookies = context.getSharedPreferences("test",
				Context.MODE_PRIVATE);
		cookie = sp_cookies.getString("logincookie", null);

		StringBuilder sb = new StringBuilder(cookie);
		sb.delete(sb.indexOf(";"), sb.length());
		sb.delete(0, sb.indexOf("=") + 1);
		cookie = sb.toString();
	}

	//获取考勤信息需要的学生id
	public void getStudentId() {
		SharedPreferences post_message = context.getSharedPreferences("postload",
				Context.MODE_PRIVATE);
		studentId = post_message.getString("attendanceid", null);
		
		this.Url += studentId;
	}
	
	public void Post() {

		Map<String, String> postDatas = new HashMap<String, String>();
		postDatas.put("JSESSIONID", cookie);
		//开始请求
		stringHttp.Post(Url, postHandler, postDatas);
		
	}
	
}
